const nextDivEl = document.querySelector(".next")
const spanEl = document.querySelector("span")
const imgEl = document.querySelector("img")
const tipDivEl = document.querySelector(".tip")
// 图片路径数组
const imgUrlArr = [
  "./images/tu_1.jpg",
  "./images/tu_2.jpg",
  "./images/tu_3.jpg"
]
// 初始索引
let index = 0
// 切换图片函数
const toggleImage = () => {
  index++
  if (index === 2) {
    nextDivEl.innerText = "查看更多"
    tipDivEl.innerText = "下载app，查看更多好友"
    nextDivEl.onclick = jumpNewPage
  }
  imgEl.src = imgUrlArr[index]
  spanEl.innerText = 2 - index
}
// 跳转新页面
const jumpNewPage = () => {
  const aEl = document.createElement("a")
  aEl.href = "./new.html"
  aEl.click()
}
nextDivEl.onclick = toggleImage